<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:f="http://xmlns.jcp.org/jsf/core"
      xmlns:p="http://primefaces.org/ui">
<h:head>
    <title>Change Destination</title>
</h:head>
<h:body>
    <f:metadata>
        <f:viewParam name="trackingId" value="#{changeDestination.trackingId}"/>
        <f:viewAction action="#{changeDestination.load}"/>
    </f:metadata>

    <div class="ui-g full-page">
        <h:form>
            <h:panelGrid columns="2" cellpadding="15">
                <p:outputLabel value="Origin:"/>
                <p:outputLabel value="#{changeDestination.cargo.originName}"/>

                <p:outputLabel value="Current destination: "/>
                <p:outputLabel
                        value="#{changeDestination.cargo.finalDestinationName}"/>

                <p:outputLabel value="New destination: "/>
                <p:selectOneMenu value="#{changeDestination.destinationUnlocode}"
                                 p:autofocus="true">
                    <f:selectItems value="#{changeDestination.potentialDestinations}"
                                   var="location" itemLabel="#{location.name}"
                                   itemValue="#{location.unLocode}"/>
                </p:selectOneMenu>

                <p:commandButton value="Cancel"
                                 action="#{changeDestinationDialog.cancel()}"/>


                <p:commandButton value="Update"
                                 action="#{changeDestination.changeDestination()}"
                                 oncomplete="window.location.replace(window.location.href);"/>
            </h:panelGrid>
        </h:form>
    </div>
</h:body>
</html>
